package com.bitBusy.manageyourriches.categories.initialValues;

import java.util.HashMap;
import java.util.Map;

import com.bitBusy.manageyourriches.R;


public enum SpendingCategoryEnum {

	Automobile("automobile", R.drawable.car, getSubcategories("automobile")),
	Bills("bills", R.drawable.invoice, getSubcategories("bills")),
	Commute("commute", R.drawable.taxi, getSubcategories("commute")),
	Entertainment("entertainment", R.drawable.movies, getSubcategories("entertainment")),
	Family("family", R.drawable.family, getSubcategories("family")),
	MedicalDental("medical", R.drawable.medicine, getSubcategories("medical")),
	Miscellaneous("miscellaneous", R.drawable.dollar, getSubcategories("miscellaneous")), 
	PersonalCare("personal care", R.drawable.personal_care, getSubcategories("personal care")),  
	Restaurant("restaurant", R.drawable.restaurant, getSubcategories("restaurant")),   
	Shopping("shopping", R.drawable.shopping, getSubcategories("shopping")),
	Unexpected("unexpected", R.drawable.cash,getSubcategories("unexpected")), 
	Vacation("vacation", R.drawable.vacation, getSubcategories("vacation"));	 
	/** Name of category*/
	private String myName;
	
	/** The Drawable resource id*/
	private int myResID;
	
	/** map of subcategory names and pic ids*/
	private Map<String, Integer> mySubcategories;
	
	/** Constructor to set id of an image to String
	 * @param name of category
	 * @param res id of image of button
	 * @param map of subcategory names and images of the category*/
	private SpendingCategoryEnum(String the_name, int the_id, Map<String, Integer> the_subcategories)
	{
		myName = the_name;
		myResID = the_id;
		mySubcategories = the_subcategories;
	}
	
	/** Method to get name of category from the enum
	 * @return the name of category
	 */
	public String getName()
	{
		return myName;
	}
	
	/** Method to get resource id of image of the category enum
	 * @return the id of image
	 */
	public int getImgResID()
	{
		return myResID;
	}
	
	/** Method to get a list of subcategory names and their imge id for the category enum
	 * @return map of string, integer list of subcategories
	 */
	public Map<String, Integer> getSubcategoryMap()
	{  
		return mySubcategories;
	}
	
	/**Method to return a list of subcategories and their images for the given category
	 * @param category
	 * @return list of subcategories and their images
	 */
	
	private static Map<String, Integer> getSubcategories(String the_categoryName)
	{
		Map<String, Integer> returnMap = new HashMap<String, Integer>();
		
		if("automobile".equals(the_categoryName))
		{
			returnMap.put("gas", R.drawable.car_gas);
			returnMap.put("insurance", R.drawable.car_insurance);
			returnMap.put("maintenance", R.drawable.car_maintenance);
			returnMap.put("repair", R.drawable.car_repair);
			return returnMap;
		}
		else if("bills".equals(the_categoryName))
		{
			returnMap.put("cable", R.drawable.bills_cable);
			returnMap.put("credit card", R.drawable.bill_creditcard);
			returnMap.put("internet", R.drawable.bills_internet);
			returnMap.put("phone", R.drawable.bills_phone);
			returnMap.put("utilities", R.drawable.bills_utilities);
			return returnMap;
		}
		else if("entertainment".equals(the_categoryName))
		{
			returnMap.put("movies", R.drawable.entertainment_movies);
			returnMap.put("music", R.drawable.entertainment_music);
			returnMap.put("sports", R.drawable.entertainment_sports);
			return returnMap;
		}
		else if("family".equals(the_categoryName))
		{
			returnMap.put("childcare", R.drawable.family_childcare);
			returnMap.put("school", R.drawable.family_school);
			return returnMap;
		}
		else if("medical".equals(the_categoryName))
		{
			returnMap.put("pharmacy", R.drawable.medicine_pharmacy);
			returnMap.put("insurance", R.drawable.medicine_insurance);
			return returnMap;
		}
		else if("miscellaneous".equals(the_categoryName))
		{
			returnMap.put("general", R.drawable.dollar);
			return returnMap;
		}
		else if("personal care".equals(the_categoryName))
		{
			returnMap.put("gym", R.drawable.personalcare_gym);
			returnMap.put("hair", R.drawable.personalcare_scissors);
			returnMap.put("nails", R.drawable.personalcare_hand);
			return returnMap;	
		}
		else if("restaurant".equals(the_categoryName))
		{
			returnMap.put("mcdonalds", R.drawable.restaurant_mcdonalds);
			returnMap.put("olive garden", R.drawable.restaurant_olivegarden);
			returnMap.put("subway", R.drawable.restaurant_subway);
			returnMap.put("wendys", R.drawable.restaurant_wendys);
			return returnMap;
		}
		else if("shopping".equals(the_categoryName))
		{
			returnMap.put("grocery", R.drawable.shopping_grocery);
			returnMap.put("clothes", R.drawable.clothes_shirt);
			returnMap.put("household", R.drawable.shopping_household);
			returnMap.put("shoes", R.drawable.shopping_shoes);
			return returnMap;
		}
		else if("commute".equals(the_categoryName))
		{
			returnMap.put("taxi", R.drawable.commute_taxi);
			returnMap.put("bus", R.drawable.commute_bus);
			returnMap.put("train", R.drawable.commute_train);
			return returnMap;
		}
		else if("unexpected".equals(the_categoryName))
		{
			returnMap.put("general", R.drawable.cash);
			return returnMap;
		}
		else if("vacation".equals(the_categoryName))
		{
			returnMap.put("general", R.drawable.vacation);
			return returnMap;
		}
		
		return null;
	}
}

